using MicroMsg.Common.Utils;
using MicroMsg.Scene;
using System;
namespace MicroMsg.Plugin.Sns.Scene
{
	public class DownloadMediaContext : IContextBase
	{
		private const string TAG = "DownloadMediaContext";
		public const int STATUS_READY = 0;
		public const int STATUS_RECVING = 1;
		public const int STATUS_COMPLETE = 3;
		public const int STATUS_ERROR = 4;
		public const int MAX_RETRY_TIMES = 1;
		private const int MAX_TIME_IN_QUEUE = 60;
		private long mInQueueTime;
		public snsMediaDownloadInfo mSnsMediaInfo;
		public DownloadMediaContext(snsMediaDownloadInfo info)
		{
			this.mSnsMediaInfo = info;
			this.mInQueueTime = (long)Util.getNowSeconds();
		}
		public bool isRunning()
		{
			return this.mSnsMediaInfo.status == 1;
		}
		public bool needToClean()
		{
			if (this.mSnsMediaInfo.status == 3 || (this.mSnsMediaInfo.status == 4 && this.mSnsMediaInfo.retryTimes > 1))
			{
				return true;
			}
			if ((long)Util.getNowSeconds() - this.mInQueueTime > 60L)
			{
				Log.smethod_1("DownloadMediaContext", "download media failed, timeout url =" + this.mSnsMediaInfo.string_0);
				return true;
			}
			return false;
		}
		public bool needToHandle()
		{
			return this.mSnsMediaInfo.status == 0 || (this.mSnsMediaInfo.status == 4 && this.mSnsMediaInfo.retryTimes <= 1);
		}
	}
}
